﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TTDataAccess;
using TTEntity;
using System.Data;

namespace TTBusiness
{
    public class clsBSOrder
    {
        clsDAOrder objDA = new clsDAOrder();
        private clsOrder getDataFromRow(DataRow dr)
        {
            try
            {
                clsOrder obj = new clsOrder();
                if (!dr.Equals(null))
                {
                    if (!dr.IsNull("ID"))
                        obj.Id = Convert.ToInt32(dr["ID"]);
                    if (!dr.IsNull("Detail"))
                        obj.Detail = dr["Detail"].ToString();
                    if (!dr.IsNull("Date"))
                        obj.Date = Convert.ToDateTime(dr["Date"]);
                    if (!dr.IsNull("FullName"))
                        obj.FullName = dr["FullName"].ToString();
                    if (!dr.IsNull("Email"))
                        obj.Email = dr["Email"].ToString();
                    if (!dr.IsNull("Phone"))
                        obj.Phone = dr["Phone"].ToString();
                    if (!dr.IsNull("Address"))
                        obj.Address = dr["Address"].ToString();
                    if (!dr.IsNull("AccountID"))
                        obj.AccountId = Convert.ToInt32(dr["AccountID"]);
                }
                return obj;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsOrder> getAll()
        {
            try
            {

                List<clsOrder> objList = new List<clsOrder>();
                DataTable dt = new DataTable();
                dt = objDA.GetAll();
                foreach (DataRow dr in dt.Rows)
                {
                    clsOrder account = new clsOrder();
                    account = getDataFromRow(dr);
                    objList.Add(account);
                }
                return objList;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Insert(clsOrder obj)
        {
            try
            {
                objDA.Insert(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Update(clsOrder obj)
        {
            try
            {
                objDA.Update(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Delete(int id)
        {
            try
            {
                objDA.Delete(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
